package Command;

import Factory.AgriculturalMachine;
import Monitor.MachineMonitor;

import java.util.ArrayList;
import java.util.List;

// 调用者 - 远程控制器
public class RemoteController {
    private MachineCommand command;
    private MachineMonitor monitor;
    private List<AgriculturalMachine> machines = new ArrayList<>();

    public RemoteController() {
        this.monitor = new MachineMonitor();
    }

    public void setCommand(MachineCommand command) {
        this.command = command;
    }

    public void executeCommand() {
        if (command != null) {
            command.execute();
        }
    }

    public void addMachine(AgriculturalMachine machine) {
        machines.add(machine);
        monitor.addMachine(machine);
    }

    public void displayMachineStatus(AgriculturalMachine machine) {
        monitor.displayMachineStatus(machine);
    }

    public void undoCommand() {
        command.undo();
    }
}
